package com.shiku.imserver.common.utils;

import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1Util {
    public static byte[] SHA1(String decript) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-1");
            digest.update(decript.getBytes());
            return digest.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

    public static String SHA1(String decript, Charset encoding) {
        return new String(SHA1(decript), encoding);
    }

    public static void main(String[] args) {
        byte[] s = SHA1("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
        System.out.println(s);
        System.out.println(BASE64Util.byteArrayToBase64(s));
    }
}
